package com.icode50.spring;

import javax.servlet.MultipartConfigElement;

import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
//上面一个相当于下面三个
//@SpringBootConfiguration
//@EnableAutoConfiguration
//@ComponentScan
@EnableScheduling//开启定时器
@EnableAsync//开启异步定时器处理
@ServletComponentScan
@EnableProcessApplication
@MapperScan("com.icode50.spring.mapper")
public class AllenApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(AllenApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(AllenApplication.class);
    }

	//文件大小配置，启动类里面配置
	@SuppressWarnings("deprecation")
	@Bean  
    public MultipartConfigElement multipartConfigElement() {  
        MultipartConfigFactory factory = new MultipartConfigFactory();  
        //单个文件最大  
        factory.setMaxFileSize("10240KB"); //KB,MB  
        /// 设置总上传数据总大小  
        factory.setMaxRequestSize("1024000KB");  
        return factory.createMultipartConfig();  
    }
}
